package com.zanglikun.activity;

import com.zanglikun.activity.util.Activity;
import com.zanglikun.activity.util.ActivityContext;

/**
 * @author : zanglikun
 * @date : 2025/10/31 14:29
 * @desc : Copyright © zanglikun.com
 */
public class CheckInventoryActivity implements Activity {
    @Override
    public boolean execute(ActivityContext context) {
        System.out.println("【检查库存】开始检查商品库存...");
        String productId = (String) context.get("productId");
        int quantity = (Integer) context.get("quantity");

        // 模拟库存检查
        int availableStock = 100;
        if (quantity > availableStock) {
            throw new IllegalArgumentException("库存不足");
        }

        context.put("inventoryChecked", true);
        System.out.println("【检查库存】✓ 库存充足");
        return true;
    }

    @Override
    public String getName() {
        return "CheckInventoryActivity";
    }

}